package com.feather.common.converter.simple.namematch;

import com.feather.common.converter.ArrayIndex;
import com.feather.common.converter.NameMatch;

/**
 * @author flogyin
 */
public class NameMatch__Prefix_CaseMatch implements NameMatch {
	private static NameMatch__Prefix_CaseMatch	nameMatch	= new NameMatch__Prefix_CaseMatch();

	public static NameMatch instance() {
		return nameMatch;
	}

	@Override
	public int match(String prefix, String key, String field, ArrayIndex arrayindex) {
		if (!key.startsWith(prefix)) {
			return NOT_MATCH;
		}

		key = key.substring(prefix.length(), key.length());
		if (key.equals(field)) {
			return 0;
		}
		return NOT_MATCH;
	}
}
